package com.spzx.test1.t7;
/*
    并非全力
*/

import com.spzx.test1.fewu.ReentrantLockTest1;
import lombok.SneakyThrows;
import org.apache.commons.lang3.RandomUtils;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;


public class Phon {

    Lock lock = new ReentrantLock();


    @SneakyThrows

    public synchronized void call() {
        lock.lock();
        System.out.println(Thread.currentThread().getName() + "正在打电话");
        TimeUnit.SECONDS.sleep(RandomUtils.nextInt(1, 5));
        System.out.println(Thread.currentThread().getName() + "结束电话");
    lock.unlock();
    }

    @SneakyThrows
    public synchronized void sendMsg() {
        lock.lock();
        System.out.println(Thread.currentThread().getName() + "正在发短信");
        TimeUnit.SECONDS.sleep(RandomUtils.nextInt(1, 5));
        System.out.println(Thread.currentThread().getName() + "发完短信");
        lock.unlock();

    }


}
